#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
using namespace std;


class Solution {
public:
    void backtracking(vector<int> candidates, int target, int startindex, vector<vector<int>>& ans, vector<int>& path, int& sum)
    {
        if(sum == target){
            ans.push_back(path);
            return;
        }else if(sum>target){
            return;
        }
        else{
            for(int i = startindex;i<candidates.size();i++)
            {
                path.push_back(candidates[i]);
                sum+=candidates[i];
                backtracking(candidates, target, i, ans, path, sum);
                sum-=candidates[i];
                path.pop_back();
            }
        }   
        
    }
    vector<vector<int>> combinationSum(vector<int>& candidates, int target) {
        vector<vector<int>> ans;
        vector<int> path;
        int sum=0;
        for(int i=0;i<candidates.size();i++)
        {
            path.push_back(candidates[i]);
            sum+=candidates[i];
            backtracking(candidates, target, i, ans, path, sum);
            sum-=candidates[i];
            path.pop_back();    
        }
        return ans;
    }
};

int main()
{
    Solution sol;
    vector<int> candidate = {2,3,6,7};
    vector<vector<int>> ans;
    int target;
    cin>>target;
    ans = sol.combinationSum(candidate,target);
}